
Public Class frmSalesman

    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents cmdcancel As System.Windows.Forms.Button
    Friend WithEvents cmdsave As System.Windows.Forms.Button
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents txtmobile As System.Windows.Forms.TextBox
    Friend WithEvents txtcontact As System.Windows.Forms.TextBox
    Friend WithEvents txtadderss As System.Windows.Forms.TextBox
    Friend WithEvents txtSalesman As System.Windows.Forms.TextBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents LstBoxSalesmen As System.Windows.Forms.ListBox
    Friend WithEvents txtInfo2 As System.Windows.Forms.TextBox
    Friend WithEvents txtInfo1 As System.Windows.Forms.TextBox
    Friend WithEvents txtCode As System.Windows.Forms.TextBox
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents chkstatus As System.Windows.Forms.CheckBox
    Friend WithEvents txtemail As System.Windows.Forms.TextBox
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Label12 As System.Windows.Forms.Label
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents Label17 As System.Windows.Forms.Label
    Friend WithEvents cmbCompany As System.Windows.Forms.ComboBox
    Friend WithEvents Label13 As System.Windows.Forms.Label
    Friend WithEvents Label9 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmSalesman))
        Me.cmdcancel = New System.Windows.Forms.Button
        Me.cmdsave = New System.Windows.Forms.Button
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.cmbCompany = New System.Windows.Forms.ComboBox
        Me.LstBoxSalesmen = New System.Windows.Forms.ListBox
        Me.Label17 = New System.Windows.Forms.Label
        Me.txtmobile = New System.Windows.Forms.TextBox
        Me.txtCode = New System.Windows.Forms.TextBox
        Me.txtSalesman = New System.Windows.Forms.TextBox
        Me.txtInfo2 = New System.Windows.Forms.TextBox
        Me.txtInfo1 = New System.Windows.Forms.TextBox
        Me.chkstatus = New System.Windows.Forms.CheckBox
        Me.txtemail = New System.Windows.Forms.TextBox
        Me.txtcontact = New System.Windows.Forms.TextBox
        Me.Label12 = New System.Windows.Forms.Label
        Me.Label11 = New System.Windows.Forms.Label
        Me.Label10 = New System.Windows.Forms.Label
        Me.Label8 = New System.Windows.Forms.Label
        Me.txtadderss = New System.Windows.Forms.TextBox
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label7 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label13 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label9 = New System.Windows.Forms.Label
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'cmdcancel
        '
        Me.cmdcancel.BackColor = System.Drawing.Color.Transparent
        Me.cmdcancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cmdcancel.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdcancel.Image = CType(resources.GetObject("cmdcancel.Image"), System.Drawing.Image)
        Me.cmdcancel.ImageAlign = System.Drawing.ContentAlignment.TopCenter
        Me.cmdcancel.Location = New System.Drawing.Point(581, 372)
        Me.cmdcancel.Name = "cmdcancel"
        Me.cmdcancel.Size = New System.Drawing.Size(64, 48)
        Me.cmdcancel.TabIndex = 10
        Me.cmdcancel.Text = "E&xit"
        Me.cmdcancel.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.cmdcancel.UseVisualStyleBackColor = False
        '
        'cmdsave
        '
        Me.cmdsave.BackColor = System.Drawing.Color.Transparent
        Me.cmdsave.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cmdsave.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdsave.Image = CType(resources.GetObject("cmdsave.Image"), System.Drawing.Image)
        Me.cmdsave.ImageAlign = System.Drawing.ContentAlignment.TopCenter
        Me.cmdsave.Location = New System.Drawing.Point(515, 372)
        Me.cmdsave.Name = "cmdsave"
        Me.cmdsave.Size = New System.Drawing.Size(64, 48)
        Me.cmdsave.TabIndex = 9
        Me.cmdsave.Text = "&Save"
        Me.cmdsave.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.cmdsave.UseVisualStyleBackColor = False
        '
        'GroupBox1
        '
        Me.GroupBox1.BackColor = System.Drawing.Color.Transparent
        Me.GroupBox1.Controls.Add(Me.cmbCompany)
        Me.GroupBox1.Controls.Add(Me.LstBoxSalesmen)
        Me.GroupBox1.Controls.Add(Me.Label17)
        Me.GroupBox1.Controls.Add(Me.txtmobile)
        Me.GroupBox1.Controls.Add(Me.txtCode)
        Me.GroupBox1.Controls.Add(Me.txtSalesman)
        Me.GroupBox1.Controls.Add(Me.txtInfo2)
        Me.GroupBox1.Controls.Add(Me.txtInfo1)
        Me.GroupBox1.Controls.Add(Me.chkstatus)
        Me.GroupBox1.Controls.Add(Me.txtemail)
        Me.GroupBox1.Controls.Add(Me.txtcontact)
        Me.GroupBox1.Controls.Add(Me.Label12)
        Me.GroupBox1.Controls.Add(Me.Label11)
        Me.GroupBox1.Controls.Add(Me.Label10)
        Me.GroupBox1.Controls.Add(Me.Label8)
        Me.GroupBox1.Controls.Add(Me.txtadderss)
        Me.GroupBox1.Controls.Add(Me.Label4)
        Me.GroupBox1.Controls.Add(Me.Label7)
        Me.GroupBox1.Controls.Add(Me.Label3)
        Me.GroupBox1.Controls.Add(Me.Label5)
        Me.GroupBox1.Controls.Add(Me.Label6)
        Me.GroupBox1.Controls.Add(Me.Label2)
        Me.GroupBox1.Controls.Add(Me.Label13)
        Me.GroupBox1.Controls.Add(Me.Label1)
        Me.GroupBox1.Controls.Add(Me.cmdsave)
        Me.GroupBox1.Controls.Add(Me.cmdcancel)
        Me.GroupBox1.Location = New System.Drawing.Point(9, 26)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(660, 437)
        Me.GroupBox1.TabIndex = 3
        Me.GroupBox1.TabStop = False
        '
        'cmbCompany
        '
        Me.cmbCompany.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbCompany.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmbCompany.FormattingEnabled = True
        Me.cmbCompany.Location = New System.Drawing.Point(116, 21)
        Me.cmbCompany.Name = "cmbCompany"
        Me.cmbCompany.Size = New System.Drawing.Size(240, 26)
        Me.cmbCompany.TabIndex = 26
        '
        'LstBoxSalesmen
        '
        Me.LstBoxSalesmen.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.LstBoxSalesmen.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.LstBoxSalesmen.ItemHeight = 18
        Me.LstBoxSalesmen.Location = New System.Drawing.Point(381, 34)
        Me.LstBoxSalesmen.Name = "LstBoxSalesmen"
        Me.LstBoxSalesmen.Size = New System.Drawing.Size(264, 326)
        Me.LstBoxSalesmen.TabIndex = 11
        '
        'Label17
        '
        Me.Label17.AutoSize = True
        Me.Label17.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label17.Location = New System.Drawing.Point(380, 18)
        Me.Label17.Name = "Label17"
        Me.Label17.Size = New System.Drawing.Size(92, 18)
        Me.Label17.TabIndex = 25
        Me.Label17.Text = "Salesmen List"
        '
        'txtmobile
        '
        Me.txtmobile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtmobile.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtmobile.Location = New System.Drawing.Point(116, 310)
        Me.txtmobile.Name = "txtmobile"
        Me.txtmobile.Size = New System.Drawing.Size(240, 26)
        Me.txtmobile.TabIndex = 6
        '
        'txtCode
        '
        Me.txtCode.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtCode.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtCode.Location = New System.Drawing.Point(116, 90)
        Me.txtCode.Name = "txtCode"
        Me.txtCode.Size = New System.Drawing.Size(240, 26)
        Me.txtCode.TabIndex = 1
        '
        'txtSalesman
        '
        Me.txtSalesman.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtSalesman.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtSalesman.Location = New System.Drawing.Point(116, 54)
        Me.txtSalesman.Name = "txtSalesman"
        Me.txtSalesman.Size = New System.Drawing.Size(240, 26)
        Me.txtSalesman.TabIndex = 0
        '
        'txtInfo2
        '
        Me.txtInfo2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtInfo2.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtInfo2.Location = New System.Drawing.Point(116, 159)
        Me.txtInfo2.Name = "txtInfo2"
        Me.txtInfo2.Size = New System.Drawing.Size(240, 26)
        Me.txtInfo2.TabIndex = 3
        '
        'txtInfo1
        '
        Me.txtInfo1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtInfo1.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtInfo1.Location = New System.Drawing.Point(116, 123)
        Me.txtInfo1.Name = "txtInfo1"
        Me.txtInfo1.Size = New System.Drawing.Size(240, 26)
        Me.txtInfo1.TabIndex = 2
        '
        'chkstatus
        '
        Me.chkstatus.AutoSize = True
        Me.chkstatus.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.chkstatus.Location = New System.Drawing.Point(238, 381)
        Me.chkstatus.Name = "chkstatus"
        Me.chkstatus.Size = New System.Drawing.Size(135, 22)
        Me.chkstatus.TabIndex = 8
        Me.chkstatus.Text = "Disable Salesman"
        '
        'txtemail
        '
        Me.txtemail.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtemail.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtemail.Location = New System.Drawing.Point(116, 345)
        Me.txtemail.Name = "txtemail"
        Me.txtemail.Size = New System.Drawing.Size(240, 26)
        Me.txtemail.TabIndex = 7
        '
        'txtcontact
        '
        Me.txtcontact.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtcontact.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtcontact.Location = New System.Drawing.Point(116, 275)
        Me.txtcontact.Name = "txtcontact"
        Me.txtcontact.Size = New System.Drawing.Size(240, 26)
        Me.txtcontact.TabIndex = 5
        '
        'Label12
        '
        Me.Label12.AutoSize = True
        Me.Label12.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label12.ForeColor = System.Drawing.Color.Red
        Me.Label12.Location = New System.Drawing.Point(360, 312)
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(15, 13)
        Me.Label12.TabIndex = 19
        Me.Label12.Text = "*"
        '
        'Label11
        '
        Me.Label11.AutoSize = True
        Me.Label11.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label11.ForeColor = System.Drawing.Color.Red
        Me.Label11.Location = New System.Drawing.Point(360, 90)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(15, 13)
        Me.Label11.TabIndex = 19
        Me.Label11.Text = "*"
        '
        'Label10
        '
        Me.Label10.AutoSize = True
        Me.Label10.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label10.ForeColor = System.Drawing.Color.Red
        Me.Label10.Location = New System.Drawing.Point(360, 56)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(15, 13)
        Me.Label10.TabIndex = 19
        Me.Label10.Text = "*"
        '
        'Label8
        '
        Me.Label8.AutoSize = True
        Me.Label8.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label8.Location = New System.Drawing.Point(41, 347)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(47, 18)
        Me.Label8.TabIndex = 19
        Me.Label8.Text = "E-mail"
        '
        'txtadderss
        '
        Me.txtadderss.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtadderss.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtadderss.Location = New System.Drawing.Point(116, 194)
        Me.txtadderss.Multiline = True
        Me.txtadderss.Name = "txtadderss"
        Me.txtadderss.Size = New System.Drawing.Size(240, 64)
        Me.txtadderss.TabIndex = 4
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label4.Location = New System.Drawing.Point(41, 312)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(70, 18)
        Me.Label4.TabIndex = 19
        Me.Label4.Text = "MobileNo"
        '
        'Label7
        '
        Me.Label7.AutoSize = True
        Me.Label7.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label7.Location = New System.Drawing.Point(10, 159)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(93, 18)
        Me.Label7.TabIndex = 16
        Me.Label7.Text = "Contact Info 2"
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label3.Location = New System.Drawing.Point(29, 276)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(76, 18)
        Me.Label3.TabIndex = 18
        Me.Label3.Text = "Contact No"
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label5.Location = New System.Drawing.Point(10, 92)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(102, 18)
        Me.Label5.TabIndex = 16
        Me.Label5.Text = "Salesman Code"
        '
        'Label6
        '
        Me.Label6.AutoSize = True
        Me.Label6.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label6.Location = New System.Drawing.Point(10, 123)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(93, 18)
        Me.Label6.TabIndex = 16
        Me.Label6.Text = "Contact Info 1"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.Location = New System.Drawing.Point(46, 209)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(58, 18)
        Me.Label2.TabIndex = 17
        Me.Label2.Text = "Address"
        '
        'Label13
        '
        Me.Label13.AutoSize = True
        Me.Label13.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label13.Location = New System.Drawing.Point(10, 21)
        Me.Label13.Name = "Label13"
        Me.Label13.Size = New System.Drawing.Size(66, 18)
        Me.Label13.TabIndex = 16
        Me.Label13.Text = "Company"
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Location = New System.Drawing.Point(10, 55)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(110, 18)
        Me.Label1.TabIndex = 16
        Me.Label1.Text = "Salesman Name "
        '
        'Label9
        '
        Me.Label9.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.Label9.Dock = System.Windows.Forms.DockStyle.Top
        Me.Label9.Font = New System.Drawing.Font("Calibri", 15.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label9.ForeColor = System.Drawing.Color.White
        Me.Label9.Location = New System.Drawing.Point(0, 0)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(681, 24)
        Me.Label9.TabIndex = 24
        Me.Label9.Text = "Create Salesman"
        Me.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'frmSalesman
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.Color.LightGray
        Me.ClientSize = New System.Drawing.Size(681, 475)
        Me.ControlBox = False
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.GroupBox1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Location = New System.Drawing.Point(152, 120)
        Me.Name = "frmSalesman"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim IcData As New DmlDdl

    Dim SQLDreader As SqlClient.SqlDataReader
    Dim SalesmanId As Integer 'for updation


    Private Sub LoadSalesmen()
        LstBoxSalesmen.Items.Clear()
        Try
            SQLDreader = IcData.LoadSalesman
            While SQLDreader.Read
                LstBoxSalesmen.Items.Add(SQLDreader("Salesman"))
            End While
            SQLDreader.Close()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Gulf Chemicals")
        End Try
    End Sub
    Sub LoadCompany()
        Dim APdata As New APdataLogic
        Dim ds As DataSet
        ds = APdata.GetAllCompany()
        cmbCompany.DataSource = ds.Tables(0)
        cmbCompany.ValueMember = "CompanyID"
        cmbCompany.DisplayMember = "CompanyName"
        cmbCompany.SelectedValue = CompanyID
    End Sub
    Private Sub frmCustomerDetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Location = New Point(30, 150)
        Call LoadCompany()
        Call LoadSalesmen()
    End Sub
    Sub LoadSalesmanDetails()
        Try
            SQLDreader = IcData.LoadSalesmanDetails(txtSalesman.Text.Trim)
            While SQLDreader.Read
                SalesmanId = SQLDreader("SalesmanId")
                txtSalesman.Text = SQLDreader("Salesman")
                txtCode.Text = SQLDreader("SalesmanCode")

                txtInfo1.Text = SQLDreader("SalesmanAdr1")
                txtInfo2.Text = SQLDreader("SalesmanAdr2")

                txtadderss.Text = SQLDreader("Address")
                txtcontact.Text = SQLDreader("Phone")
                txtmobile.Text = SQLDreader("Mobile")
                txtemail.Text = SQLDreader("Email")

                If SQLDreader("Active") = 0 Then
                    chkstatus.Checked = True
                Else
                    chkstatus.Checked = False
                End If

            End While
            SQLDreader.Close()
            cmdsave.Text = "&Update"
            cmdcancel.Text = "&Cancel"
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Gulf Chemicals")
        End Try
    End Sub

    Sub Clear()
        txtSalesman.Clear()
        txtCode.Text = ""
        txtInfo1.Text = ""
        txtInfo2.Text = ""
        txtemail.Text = ""
        txtadderss.Clear()
        txtcontact.Clear()
        txtmobile.Clear()
        chkstatus.Checked = False
        txtSalesman.Focus()
    End Sub

    Function NullValidation() As Boolean
        If txtSalesman.Text = "" Then
            MsgBox("Enter the Salesman name", MsgBoxStyle.Information, "Gulf Chemicals")
            NullValidation = True
            txtSalesman.Focus()
        ElseIf txtCode.Text = "" Then
            MsgBox("Enter the Salesman code", MsgBoxStyle.Information, "Gulf Chemicals")
            NullValidation = True
            txtCode.Focus()
        ElseIf txtmobile.Text = "" Then
            MsgBox("Enter the Salesman Mobile", MsgBoxStyle.Information, "Gulf Chemicals")
            NullValidation = True
            txtmobile.Focus()
        ElseIf IcData.CheckIfExist("IfSalesmanExist", txtSalesman.Text.Trim, 0) = 1 Then
            If SalesmanId <> 0 Then : NullValidation = False : Exit Function : End If
            MsgBox("salesman already exist", MsgBoxStyle.Information, "Gulf Chemicals")
            NullValidation = True
            txtSalesman.Focus()
        ElseIf IcData.CheckIfExist("IfSalesmanExist", txtCode.Text.Trim, 1) = 1 Then
            If SalesmanId <> 0 Then : NullValidation = False : Exit Function : End If
            MsgBox("salesman code already exist", MsgBoxStyle.Information, "Gulf Chemicals")
            NullValidation = True
            txtCode.Focus()
        Else
            NullValidation = False
        End If
    End Function
    Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
        If NullValidation() = True Then Exit Sub
        If cmdsave.Text = "&Save" Then : SalesmanId = 0
        Else
            cmdsave.Text = "&Save"
            cmdcancel.Text = "E&xit"
        End If

        Dim active As Integer
        If chkstatus.CheckState = CheckState.Checked Then
            active = 0
        Else
            active = 1
        End If

        Try
            IcData.InsertUpdateSalesman(SalesmanId, txtSalesman.Text, txtCode.Text, txtInfo1.Text, txtInfo2.Text, txtadderss.Text, txtemail.Text, txtcontact.Text, txtmobile.Text, active, cmbCompany.SelectedValue)
            MsgBox("Successfully Completed", MsgBoxStyle.Information, "Gulf Chemicals")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Gulf Chemicals")
        End Try
        LoadSalesmen()
        Clear()
    End Sub
    Private Sub cmdcancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcancel.Click
        If cmdcancel.Text = "E&xit" Then
            Me.Close()
        Else
            cmdsave.Text = "&Save"
            cmdcancel.Text = "E&xit"
            Clear()
        End If
    End Sub

    Private Sub txtname_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtSalesman.KeyDown
        IcData.KeyDownEvent(e, txtSalesman, LstBoxSalesmen)
        If e.KeyCode = Keys.Enter Then
            LoadSalesmanDetails()
        End If
    End Sub

    Private Sub txtname_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSalesman.TextChanged
        IcData.TextChangeEvent(txtSalesman, LstBoxSalesmen)
    End Sub

    Private Sub lstboxcustomer_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles LstBoxSalesmen.DoubleClick
        txtSalesman.Text = LstBoxSalesmen.SelectedItem
        LoadSalesmanDetails()
    End Sub

   
End Class
